from abc import ABC, abstractmethod
import numpy as np


# noinspection PyPep8Naming,PyPep8Naming
class Problem(ABC):
    """
    问题基类
    属性:
        name: 问题名
        ...
        TODO: 还缺少上下界开闭区间的描述
    
    """
    name: str  # 问题名
    borders: np.ndarray  # 上下界
    type: str  # 问题类型
    M: int     # 目标数
    D: int     # 决策变量维度

    def __init__(self):
        assert self.name is not None
        assert self.borders is not None
        assert self.type is not None
        assert self.M is not None
        assert self.D is not None
    
    @abstractmethod
    def cal_obj(self, pop) -> None:
        pass
    
    def cal_cv(self, pop) -> None:
        pass
    
    @abstractmethod
    def get_optimal(self) -> np.ndarray:
        pass
